def solve(nums,k):
    mp={}
    pre=0
    ans=0
    for i in range(len(nums)):
        if pre in mp: mp[pre]+=1
        else: mp[pre]=1
        pre+=nums[i]
        if k-nums[i] in mp: ans+=mp[k-nums[i]]
    return ans

print(solve([1,1,1],2),solve([1,2,3],3))

    
